package com.aizuda.boot.modules.business.template.entity.vo;

import com.aizuda.boot.modules.business.contract.entity.vo.ContractFormDataDTO;
import com.aizuda.boot.modules.file.domain.vo.FileVO;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Data
@Schema(description = "按合同类型分类的合同模版列表响应")
public class ContractTemplatesByTypeRespDTO {

    @Schema(description = "合同类型分组列表")
    private List<ContractTypeGroup> contractTypeGroups;

    @Data
    @Schema(description = "合同类型分组")
    public static class ContractTypeGroup {
        @Schema(description = "合同类型ID")
        private Integer contractTypeId;

        @Schema(description = "合同类型名称")
        private String contractTypeName;

        @Schema(description = "合同类型层级 (1:一级, 2:二级, 3:三级)")
        private Integer level;

        @Schema(description = "父级合同类型ID")
        private Integer parentId;

        @Schema(description = "该类型下的子级类型列表")
        private List<ContractTypeGroup> children;

        @Schema(description = "该类型下的模版列表")
        private List<TemplateInfo> templates;
    }

    @Data
    @Schema(description = "模版信息")
    public static class TemplateInfo {
        @Schema(description = "模版ID")
        private Integer templateId;

        @Schema(description = "模版名称")
        private String templateName;

        @Schema(description = "模板编号，格式：年月日+序号，如：202506300001")
        private String templateCode;

        @Schema(description = "使用说明")
        private String usageInstructions;

        @Schema(description = "模版文件URL")
        private String templateFileUrl;

        @Schema(description = "模版文件名称")
        private String templateFileName;

        @Schema(description = "模版文件信息")
        private FileVO fileInfo;

        @Schema(description = "状态：draft 草稿，published 发布")
        private String status;

        @Schema(description = "创建时是否可编辑")
        private Boolean editableWhenCreating;

        @Schema(description = "创建时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime createdAt;

        @Schema(description = "更新时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime updatedAt;

        @Schema(description = "发布者ID")
        private Long publisherId;

        @Schema(description = "发布者姓名")
        private String publisherName;

        @Schema(description = "发布者昵称")
        private String publisherAliasName;

        @Schema(description = "发布者头像")
        private String publisherAvatar;
        
        @Schema(description = "合同表单数据")
        private ContractFormDataDTO content;
        
        @Schema(description = "最后一级的合同类型ID")
        private Integer contractTypeId;
    }
} 